package com.cs.club.domain.service.impl;

import com.cs.club.common.entity.ErrorCode;
import com.cs.club.common.utlis.ThrowUtils;
import com.cs.club.domain.bos.ClubActivitiesBO;
import com.cs.club.domain.service.ClubActivitiesDomainService;
import com.cs.club.domain.service.ClubAssetsDomainService;
import com.cs.club.infra.basic.entity.ClubActivities;
import com.cs.club.infra.basic.entity.ClubAssets;
import com.cs.club.infra.basic.service.ClubActivitiesService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class ClubActivitiesDomainServiceImpl implements ClubActivitiesDomainService {

    @Resource
    private ClubActivitiesService clubActivitiesService;

    @Override
    public Boolean addClubActivities(ClubActivitiesBO clubActivitiesBO) {
        // 参数校验
        ThrowUtils.throwIf(clubActivitiesBO.getActivitiesName() == null, ErrorCode.PARAMS_ERROR,"活动名称呢？");
        ClubActivities clubActivities = new ClubActivities();
        BeanUtils.copyProperties(clubActivitiesBO, clubActivities);
        return clubActivitiesService.addClubActivities(clubActivities);
    }

    @Override
    public Boolean deleteClubActivities(ClubActivitiesBO clubActivitiesBO) {
        // 参数校验
        ThrowUtils.throwIf(clubActivitiesBO.getBusinessId() == null, ErrorCode.PARAMS_ERROR,"活动名称呢？");
        ClubActivities clubActivities = new ClubActivities();
        BeanUtils.copyProperties(clubActivitiesBO, clubActivities);
        return clubActivitiesService.deleteClubActivities(clubActivities);
    }

    @Override
    public Boolean updateClubActivities(ClubActivitiesBO clubActivitiesBO) {
        // 参数校验
        ThrowUtils.throwIf(clubActivitiesBO.getBusinessId() == null, ErrorCode.PARAMS_ERROR,"活动名称呢？");
        ClubActivities clubActivities = new ClubActivities();
        BeanUtils.copyProperties(clubActivitiesBO, clubActivities);
        return clubActivitiesService.updateClubActivities(clubActivities);
    }
}
